ot_keyfile_copy_group: return FALSE on invalid inputs
authorGiuseppe Scrivano <gscrivan@redhat.com>
Thu, 5 Mar 2015 13:40:00 +0000 (14:40 +0100)
committerGiuseppe Scrivano <gscrivan@redhat.com>
Fri, 6 Mar 2015 17:45:37 +0000 (18:45 +0100)
The function returns a gboolean, replace g_return_if_fail with
g_return_val_if_fail.

Add similar checks to the other functions.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
src/libotutil/ot-keyfile-utils.c

index 6a89357172c8b08b84aba0e48322da80c3d1caec..c585108b8badcbb92f1a6bd440861d92331cfd05 100644 (file)
@@ -38,6 +38,10 @@ ot_keyfile_get_boolean_with_default (GKeyFile      *keyfile,
   GError *temp_error = NULL;
   gboolean ret_bool;
 
+  g_return_val_if_fail (keyfile != NULL, ret);
+  g_return_val_if_fail (section != NULL, ret);
+  g_return_val_if_fail (value != NULL, ret);
+
   ret_bool = g_key_file_get_boolean (keyfile, section, value, &temp_error);
   if (temp_error)
     {
@@ -71,6 +75,10 @@ ot_keyfile_get_value_with_default (GKeyFile      *keyfile,
   GError *temp_error = NULL;
   gs_free char *ret_value = NULL;
 
+  g_return_val_if_fail (keyfile != NULL, ret);
+  g_return_val_if_fail (section != NULL, ret);
+  g_return_val_if_fail (value != NULL, ret);
+
   ret_value = g_key_file_get_value (keyfile, section, value, &temp_error);
   if (temp_error)
     {
@@ -101,9 +109,9 @@ ot_keyfile_copy_group (GKeyFile   *source_keyfile,
   gsize length, ii;
   gboolean ret = FALSE;
 
-  g_return_if_fail (source_keyfile != NULL);
-  g_return_if_fail (target_keyfile != NULL);
-  g_return_if_fail (group_name != NULL);
+  g_return_val_if_fail (source_keyfile != NULL, ret);
+  g_return_val_if_fail (target_keyfile != NULL, ret);
+  g_return_val_if_fail (group_name != NULL, ret);
 
   keys = g_key_file_get_keys (source_keyfile, group_name, &length, NULL);